home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 6.5 KB | 214 lines | [TEXT/MPS ] |
- #########################################################################
- # script PointAndSee( )
- #########################################################################
- # Description: Point to something on the target, and when the mouse
- # stops moving the script prints whatever VU sees there.
- # For Control Panels in Control_Panel_List, there is an
- # automatic -89 horizontal offset before comparing, if the
- # Control_Panel_Offset parameter is true.
- # Version: 1.07
- # Parameters: see below
- # Returns: nothing
- # History:
- # 08/25/93 SBR Created
- # 09/08/94 SBR added window_ordinality parameter
- #########################################################################
- Script PointAndSee
- (
- window_ordinality := 1,
- waitTime := 0,
- moreDetail := 0,
- print_new_window := true,
- Control_Panel_Offset := false,
- Control_Panel_List := { 'Date & Time','Easy Access','General Controls','Keyboard','Map',
- 'Memory','Monitors','Mouse','Numbers','Sound'}
- )
- begin
- global gActorName;
-
- tName := (match [target]).t;
- if tName
- begin
- tName := "PointAndSee {tName}";
- gActorName := tName;
- actorName(gActorName);
- end;
- else begin
- SysBeep();
- println; println; println; println; println;
- println (*You Idiot!*) "You forgot to select a target!";
- exit;
- end;
-
- println "Point to something on the target, and when the mouse stops moving the script prints";
- println "whatever VU sees there. For Control Panels in Control_Panel_List, there is an ";
- println "Note for VU 2.0.1 users ONLY: For Control Panels in the Control_Panel_List, there is an ";
- println "automatic -89 horizontal offset before comparing. Set the Control_Panel_Offset ";
- println "parameter to true to enable the offset. ";
-
- previousDescriptor := [contentItem o:32766];
- previousWindow := [window t:'12345 not a name']; #bogus starting value
- currentWindow := [window t:'54321 Paul Is Dead']; #bogus starting value
-
- if not Control_Panel_Offset # turn off the offset for all CPs
- Control_Panel_List := {};
-
- while true
- begin
- mouseLocation := GetStoppedMousePosition( waitTime );
-
- currentWindow := match[window o:window_ordinality]!;
- if currentWindow # do nothing if there is not a window
- begin
- if previousWindow <> currentWindow
- begin
- gActorName := "new window…";
- actorName(gActorName);
-
- match [window o:window_ordinality k:?currentWindowItems];
- previousWindow := currentWindow;
- println;
- println currentWindow;
- if print_new_window
- begin
- for each kItem in currentWindow.k
- println kItem;
- println;
- end;
-
- if isMember(currentWindow.t, Control_Panel_List)
- begin
- cpOffset := -89;
- println "**** Using -89 horizontal offset for this Control Panel ****";
- end;
- else cpOffset := 0;
-
- previousDescriptor := [contentItem o:32766];
- end;
-
- if PointIsInRect( mouseLocation, currentWindow.r )
- begin
- if gActorName <> "scanning…"
- begin
- gActorName := "scanning…";
- actorName(gActorName);
- end;
-
- for each currentWindowItem in currentWindowItems
- begin
- if PointIsInRect( mouseLocation, currentWindowItem.r, cpOffset ) and
- currentWindowItem.o <> previousDescriptor.o
- begin
- previousDescriptor := currentWindowItem;
-
- if moreDetail
- println match currentWindowItem!;
- else println currentWindowItem;
-
- previousDescriptor := currentWindowItem;
- end;
- end;
- end;
- else if gActorName <> "out of window"
- begin
- gActorName := "out of window";
- actorName(gActorName);
- end;
- end;
- end;
- end;
-
-
- #########################################################################
- # task GetStoppedMousePosition( waitTime )
- # Description: Waits for the mouse to come to rest for more than
- # waitTime seconds.
- # Parameters: waitTime integer of seconds
- # Returns: The position the mouse stopped in.
- # History:
- # 08/25/93 SBR Created
- # 03/05/94 SBR Modified for faster mouse checking
- #########################################################################
- task GetStoppedMousePosition( waitTime := 0 )
- begin
- global gPreviousPosition, gActorName;
-
- if not gPreviousPosition # force mismatch first time through
- begin
- gPreviousPosition := {1,1};
- currentPosition := {2,2};
- end;
- else currentPosition := (match [mouse]).p;
-
- while gPreviousPosition = currentPosition # require some movement to start
- begin
- if gActorName <> "mouse is stopped" and gActorName <> "out of window"
- begin
- gActorName := "mouse is stopped";
- actorName(gActorName);
- end;
-
- currentPosition := (match [mouse]).p;
- end;
-
- while gPreviousPosition <> currentPosition # require ZERO movement to stop
- begin
- #if gActorName <> "mouse is moving…"
- if gActorName <> "scanning…"
- begin
- #gActorName := "mouse is moving…";
- gActorName := "scanning…";
- actorName(gActorName);
- end;
-
- gPreviousPosition := (match [mouse]).p;
-
- if waitTime = 0; # Adjust response time between actual
- else if waitTime > 0 # stop and detected stop. If waitTime
- wait(waitTime); # is > 0, wait that # of seconds, if
- else if waitTime < 0 # it is < 0, loop that # of times,
- for i := -1 to waitTime step -1; # which is less accurate but shorter.
-
- currentPosition := (match [mouse]).p;
- end;
-
- return currentPosition;
- end;
-
-
- #########################################################################
- # task PointIsInRect( pointList, rectList, delta_h )
- # Description: Waits for the mouse to come to rest for more than
- # waitTime seconds.
- # Parameters: pointList, { x,y } point where the mouse is
- # rectList, { l,t,r,b } item rect the mouse might be over
- # delta_h := 0 horizontal offset for System 7 control panels
- # Returns: True if the mouse is currently in the rectangle, else false
- # History:
- # 08/25/93 SBR Created
- # 03/02/94 SBR Optimized for no delta_h.
- #########################################################################
- task PointIsInRect
- (
- pointList, # { x,y } point where the mouse is
- rectList, # { left,top,right,bottom } item rect the mouse might be over
- delta_h := 0 # horizontal offset for System 7 control panels
- )
- begin
- #println pointList; # { x,y }
- #println rectList; # { left,top,right,bottom }
- if not delta_h
- return (pointList[1] >= rectList[1]) and
- (pointList[1] <= rectList[3]) and
- (pointList[2] >= rectList[2]) and
- (pointList[2] <= rectList[4]);
- else return (pointList[1] >= rectList[1] + delta_h) and
- (pointList[1] <= rectList[3] + delta_h) and
- (pointList[2] >= rectList[2]) and
- (pointList[2] <= rectList[4]);
- end;
-
-
-
-
-